function failure_rate_VaRCov = BacktestVaR(rPortfolio, VaRdown)
   
    %Estimate failure rate
    failure_rate_VaRCov = 0;
    if (length(VaRdown)==1)
    for i=1:length(rPortfolio)
        if (rPortfolio(i) < VaRdown) %| (rPortfolio(i) > VaRup)
            failure_rate_VaRCov = failure_rate_VaRCov+1;
        end
    end
    else
    for i=1:length(rPortfolio)
        if (rPortfolio(i) < VaRdown(i)) %| (rPortfolio(i) > VaRup(i))
            failure_rate_VaRCov = failure_rate_VaRCov+1;
        end
    end
    end
    
    failure_rate_VaRCov = failure_rate_VaRCov/length(rPortfolio);
    